# str
import time

"""
class People:
    def __init__(self,name,age):
        self.name = name
        self.age = age
    def __str__(self): # 在对象打印时自动出发，可以用来定义对象被打印的输出信息
        return '<name :%s age:%s>'%(self.name,self.age)
    def run(self):
        return self.name
# obj = People("关博文",99)
# print(obj) #原来是：地址值   现在变成了：<name :关博文 age:99>
# print(obj.run())
"""
# del
"""
class Foo:
    def __init__(self,x,filepath,encoding='utf8'):
        self.x = x
        self.f = open(filepath,'r',encoding=encoding)
    def __del__(self):
        print("__del__正在运行")
        self.f.close()
# obj = Foo(1,'a.txt')
# print('不是对象生成运行__del__，对象正在使用的时候不会运行')
# time.sleep(3)
# # 对象使用不会运行__del__
# print(obj.f.read())
"""
# call
class Foo:
    def __init__(self,name,age):
        self.name = name
        self.age = age
    def __call__(self,*args,**kwargs):
        print(args,kwargs) #self,
    def run(self):
        print("run")
obj1 = Foo("关博文",29)
# obj1.run()
# 对象被调用时会自动触发该方法
obj1(5,5,5,姓名="关博文",年龄=29) # __call__ 调用










